﻿@model PagedList.IPagedList<FTBS.Models.Entities.Concert.TicketCartConcertEntity>
@using PagedList.Mvc;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />

@{
    ViewBag.Title = "Quản lý vé đã đặt";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    var isSortDes = (bool)ViewBag.IsSortDes;    
}

<legend style="margin-top: 10px">QUẢN LÝ ĐẶT VÉ</legend>

<div>
    <div>
        @using (Html.BeginForm("Index", "TicketCart", FormMethod.Get))
        {
            <p>
                Tìm kiếm: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
                <input class="inverse" type="submit" value="Tìm" />
            </p>
        }
    </div>

    <div style="height: 380px">
        <table class="table striped bordered hovered">
            <tr>
                <th>
                    @Html.ActionLink("Mã số đặt vé", "Index", new { sortOrder = ViewBag.NameSortParm, isSortDescending = isSortDes })
                </th>
                <th>
                    @Html.ActionLink("Người đặt vé", "Index", new { sortOrder = "user_desc", isSortDescending = isSortDes })
                </th>
                <th>
                    @Html.ActionLink("Tổng giá tiền", "Index", new { sortOrder = "price_desc", isSortDescending = isSortDes })
                </th>
                <th>
                    @Html.ActionLink("Số vé đã đặt", "Index", new { sortOrder = "totalTicket_desc", isSortDescending = isSortDes })
                </th>
                <th>
                    @Html.ActionLink("Tình trạng thanh toán", "Index", new { sortOrder = "status_desc", isSortDescending = isSortDes })
                </th>
                <th>
                    @Html.ActionLink("Ghi chú", "Index", new { sortOrder = "note_desc", isSortDescending = isSortDes })
                </th>
                <th>
                    @Html.ActionLink("Ngày đặt", "Index", new { sortOrder = "dateCreate_desc", isSortDescending = isSortDes })
                </th>
                <th></th>
            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td style="text-align: center">
                        @Html.DisplayFor(cartId => item.CartId)
                    </td>
                    <td>
                        @Html.DisplayFor(username => item.UserName)
                    </td>
                    <td style="text-align: right">
                        @{
                var totalPrice = item.TotalPrice.ToString(@"0,000");
                        }
                        @totalPrice
                    </td>
                    <td style="text-align: right">
                        @Html.DisplayFor(totalTicket => item.TotalTicket)
                    </td>
                    <td style="text-align: center">
                        @Html.DisplayFor(status => item.StatusPayment)
                    </td>
                    @{
                        string[] noteValue = new string[2];
                        bool isHaveSpecial = false;
                        string noteItem = string.Empty;
                        if (item.Note != null && item.Note.Contains('+'))
                        {
                            noteValue = item.Note.Split('+');
                            isHaveSpecial = true;
                        }
                        else
                        {
                            noteItem = item.Note;
                        }                           
                    }

                    @if (isHaveSpecial)
                    {
                        <td>
                            @noteValue[0]
                            <br />
                            @noteValue[1]
                        </td>
                            
                    }
                    else
                    {
                        <td>@noteItem</td>
                    }
                    <td style="text-align: center">
                        @{
                    var createTimeValue = item.CreateTime.ToString("dd/MM/yyyy");
                        }
                        @createTimeValue
                    </td>
                    <td style="width: 148px">
                        @Html.ActionLink("Thông tin thanh toán", "PaymentDetail", new { id = item.CartId })
                    </td>
                </tr>
            }
        </table>
    </div>

    <div style="float: right">
        <br />
        <div style="float: right">
            Trang @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) của @Model.PageCount trang
        </div>
        <div>
            @Html.PagedListPager(Model, page => Url.Action("Index",
            new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
        </div>
    </div>
</div>
